﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using ExtBusiness;

public partial class WebPubManager_SubmitGenerate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["action"] == "submit")
        {
            string strFlag = ClsSubmitInfo.GetIsSubmit(Request.Params["id"]);
            if (strFlag != null)
            {
                if (strFlag != "")
                {
                    if (strFlag == "0")
                    {
                        ClsSubmitInfo.UpdateIsFlag(Request.Params["id"], 1);
                    }
                    else
                    {
                        ClsSubmitInfo.UpdateIsFlag(Request.Params["id"], 0);
                    }
                }
            }
        }

        if (!IsPostBack)
        {
            GridviewDatabind();
            LabelTitle.Text = Request["datatype"];
        }
    }

    #region 数据绑定
    private void GridviewDatabind()
    {
        DataTable dt = ClsSubmitInfo.GetSubmit();
        gridviewCar.DataSource = dt;
        gridviewCar.RecordCount = dt.Rows.Count;
        gridviewCar.DataBind();
    }
    #endregion

    /// <summary>
    /// datagrid数据加载
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void recvgrid_OnLoadData(object sender, EventArgs e)
    {
        this.GridviewDatabind();
    }

    #region 行创建
    protected void gridviewCar_RowCreated(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.DataRow:
                DataRowView dtrv = e.Row.DataItem as DataRowView;
                if (dtrv == null)
                {
                    break;
                }
                break;
        }
    }
    #endregion

    protected string GetIsSubmit(IDataItemContainer row)
    {
        string strHtml = string.Empty;
        if (DataBinder.Eval(row.DataItem, "is_submit").ToString() == "0")
        {
            strHtml = "不允许";
        }
        else if (DataBinder.Eval(row.DataItem, "is_submit").ToString() == "1")
        {
            strHtml = "允许";
        }
        else
        {
            strHtml = "";
        }

        return strHtml;
    }

    #region 返回菜单管理主界面
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("WorkFlowPubAdd.aspx?id=" + Request["flowid"]);
    }
    #endregion
}
